<?php

declare(strict_types=1);

namespace app\shop\controller\admin\data;

use think\Request;
use sheep\controller\Backend;
use sheep\controller\traits\Crud;
use app\shop\model\data\Richtext as RichtextModel;

class Richtext extends Backend
{
    use Crud;
    protected $model = null;
    protected $isPaginate = true;
    protected $onlyParams = ['title', 'content'];

    public function initialize()
    {
        $this->model = new RichtextModel();
    }

    public function select(Request $request)
    {
        $type = $request->param('type', 'page');

        $data = $this->model->sheepFilter();

        if ($type == 'select') {
            // 普通结果
            $data = $data->select();
        } elseif ($type == 'find') {
            $data = $data->find();
        } else {
            // 分页结果
            $data = $data->paginate(request()->param('list_rows', 10));
        }

        return success('操作成功', $data);
    }
}
